{extend name='base'} 
{block name='content'}
	<div class="box1">
		<div class="row">
			<div class="col-xs-12">
				<div class="block">
					<a href="{:url('add',['m'=>$Request.param.m])}" class="btn btn-primary">添加</a>
					<a href="javascript:;" class="btn btn-default">测试</a>
				</div>
				<div class="table-responsive">
					<table class="table table-hover table-bordered"> 
					      <thead>
					        <tr>
					          <th width="50">ID</th> 
					          <th width="200">数据表</th> 
					          <th>管理</th> 
					          <th width="150">操作</th> 
					        </tr>
					      </thead>
					      <tbody> 
					      	{volist name="list" id="data"}
					      		<tr>
					      			<td>{$data.id}</td>
					      			<td>cqz_{$data.name}({$data.title})</td>
					      			<td> 
					      				<div style="padding: 10px;">
					      					<div style="margin-bottom: 10px;">
					      						<a href="{:url('info/add',['m'=>'field','table_name'=>$data.name])}" class="btn btn-primary btn-xs">添加字段</a>
					      						<a href="{:url('field/createForm',['table_name'=>$data.name])}" class="btn btn-warning btn-xs">生成表单</a>
					      					</div>
					      					
					      					<table class="table table-bordered">
					      						{volist name=":model('table')->fieldList($data.name)" id="field"}
					      							<tr>
					      								<td width="50"><input type="text" class="myorder" style="width: 50px;" value="{$field.myorder}" data-id='{$field.id}'></td>
					      								<td>{$field.name}</td>
					      								<td>{$field.title}</td>
					      								<td>
					      									<label class="checkbox-inline">
					      										<input type="checkbox" class="q_h_input" data-field='h_input' data-id='{$field.id}' <?=$field['h_input']==1?'checked':''?>>录入
					      									</label>
					      								</td>
					      								<td>
					      									<label class="checkbox-inline">
					      										<input type="checkbox" class="q_h_input" data-field='q_input' data-id='{$field.id}' <?=$field['q_input']==1?'checked':''?>>投稿
					      									</label>
					      								</td>
					      								<td width="100">
					      									<a href="{:url('info/edit',['m'=>'field','id'=>$field.id])}">编辑</a>
					      									<a href="{:url('info/del',['m'=>'field','id'=>$field.id])}">删除</a>
					      								</td> 
					      							</tr>
					      						{/volist}
					      					</table>
					      				</div>
					      			</td>
					      			<td>
					      				<a href="{:url('edit',['m'=>'table','id'=>$data.id])}" class="btn btn-primary btn-sm">编辑</a>
					      				<a href="{:url('del',['m'=>'table','id'=>$data.id])}" class="btn btn-danger btn-sm" onclick="return confirm('确定删除吗?');">删除</a>
					      			</td>
					      		</tr>
					      	{/volist}
					      </tbody>
					</table>
				</div>
				<div class="page">
					{$list->render()}
				</div>
			</div>
		</div>
	</div>

<script type="text/javascript">
	$('.myorder').change(function () {
		$.post("{:url('field/myorder')}",{id:$(this).attr('data-id'),myorder:$(this).val()},function (data) {
			layer.msg(data);
		})
	})


	$('.q_h_input').change(function () {
		var field=$(this).attr('data-field');
		var id=$(this).attr('data-id');
		var value=0;
		if ($(this).prop('checked')) {
			value=1;
		}
		$.post("{:url('field/isInput')}",{field:field,id:id,value:value},function (data) {
			layer.msg(data);
		});
	});
</script>
{/block}